package com.morehair.service.wx.impl;

import com.morehair.bean.bo.WxFeedbackBo;
import com.morehair.bean.pojo.Feedback;
import com.morehair.bean.pojo.User;
import com.morehair.mapper.FeedbackMapper;
import com.morehair.service.wx.WxFeedbackService;
import com.morehair.utils.GetNowUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class WxFeedbackServiceImp implements WxFeedbackService {

    @Autowired
    FeedbackMapper feedbackMapper;

    @Override
    public void submit(WxFeedbackBo feedbackBo) {
        User user = GetNowUser.getUser();
        Integer userId = user.getId();
        String username = user.getUsername();
        Feedback feedback = new Feedback();
        feedback.setAddTime(new Date());
        feedback.setUpdateTime(new Date());
        feedback.setStatus(0);
        feedback.setContent(feedbackBo.getContent());
        feedback.setDeleted(false);
        feedback.setFeedType(feedbackBo.getFeedType());
        feedback.setHasPicture(feedbackBo.isHasPicture());
        feedback.setMobile(feedbackBo.getMobile());
        feedback.setUserId(userId);
        feedback.setPicUrls(null);
        feedback.setUsername(username);
        feedbackMapper.insert(feedback);
    }
}
